#ifndef BACKGROUNDROLLINGSCENE_H
#define BACKGROUNDROLLINGSCENE_H
#include<QGraphicsScene>
#include<QRandomGenerator>
class QTimer;
class ScoreSprite;
class NoteSprite;
extern QTimer globalTicker;
class BackGroundRollingScene:public QGraphicsScene
{
    Q_OBJECT
    float offset,runSpd;
    QImage backGroundimg,GameOverImg;
    void drawBackground(QPainter *painter, const QRectF &rect);
    void drawForeground(QPainter *painter, const QRectF &rect);
public:
    enum tagState{waiting,playing,gameover};
private:
    enum tagState state;
    int tickCnt,PipeCountDown;
    const float speed=3;
    const float gap=90;
    const int pipeSummonT=80,pipeSummonTmax=95;
    ScoreSprite*s;
    NoteSprite*note;
    QRandomGenerator*randomGenerator;
public:
    BackGroundRollingScene();
    enum tagState getstate()const;
    void Init();
    int getScore()const;
    void setNote(const QString&NoteText,const Qt::GlobalColor=Qt::white);
    void setNoteCol(const Qt::GlobalColor);
    void setNoteCol(QRgb col);
    void setNotePoint(float pnt);
private slots:
    void tick();
    void onGameBegin();
    void onGameOver();
    void onGameRestart();
};

#endif // BACKGROUNDROLLINGSCENE_H
